package singleton;

/**
 * 定位系统单例实现
 */
public class PositioningSystem {
    private static PositioningSystem instance;
    private String currentPosition = "0,0"; // 默认位置

    // 私有构造函数防止外部实例化
    private PositioningSystem() {
        System.out.println("初始化定位系统");
    }

    // 线程安全的单例获取方法
    public static synchronized PositioningSystem getInstance() {
        if (instance == null) {
            instance = new PositioningSystem();
        }
        return instance;
    }

    public void updatePosition(String position) {
        System.out.println("更新位置: " + position);
        currentPosition = position;
    }

    public String getCurrentPosition() {
        return currentPosition;
    }
}
